#!/bin/bash

pushd "$(dirname $0)" >/dev/null && source common.sh && popd >/dev/null

cd $APP_DIR

# Check if anything has changed since the last update.
if [ -f messages.timestamp ]; then
  changed=$(find . ../tools/setup.py \
      \( -name '*.py' -or -name '*.html' -or -name locale.js -or -name django.po \) \
      -newer messages.timestamp)
else
  changed=yes
fi

# If something has changed since the last update, do the update.
if [ -n "$changed" ]; then
  ../tools/extract_messages ../tools/setup.py static/locale.js && \
      $APPENGINE_DIR/lib/django/django/bin/compile-messages.py "$@" && \
      $PYTHON -c 'import setup; setup.setup_js_messages()' && \
      touch messages.timestamp
else
  echo 'Message files are up to date.'
fi

../tools/find_missing_translations
